<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="/resource/UserPwoer.tld" prefix="p"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("fnId", request.getAttribute("fnId"));
	pageContext.setAttribute("userPwoer", request.getSession().getAttribute("userPwoer"));
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
</head>
<body class="gray-bg">
	<nav class="huiNav">
		<i class="fa fa-home"></i> 首页 <span>&gt;</span>业务管理<span>&gt;</span>退款申请
		<a class="btn btn-info  btn-sm pull-right"
			href="javascript:location.replace(location.href);" title="刷新"><i
			class="fa fa-refresh"></i></a>
	</nav>
		
	<div class="ibox-content">
	<!-- 搜索框部分start -->
	<p:btn value="serch">
		<form class="form-inline" id="serchform">
			<div class="form-group mr-20">
				<label for="exampleInputName2">交易状态</label>
				<select name="status" class="form-control" size="1" >
				<option value="">--请选择--</option>
				<option value="1">提现成功</option>
				<option value="2">正在处理</option>
				<option value="3">不予处理</option>
			</select>
			</div>
			<div class="form-group mr-20">
				<label for="exampleInputName2">支付宝帐号</label>
				<input type="text" name="userTel" class="form-control"/>
			</div>
			<div class="form-group mr-20">
				<label for="exampleInputName2">提现人名称</label>
				<input type="text" name="userName" class="form-control"/>
			</div>
			<br/>
			<br/>
			<div class="form-group mr-20">
				<label for="exampleInputName2">申请时间</label>
				<input name="startTime" type="text" class="form-control" role="datepicker" readonly="readonly"> --- 
				<input type="text" name="overTime" class="form-control" role="datepicker" readonly="readonly"/>
			</div>
			<div class="form-group mr-20">
				<label for="exampleInputName2">金额</label>
				<input name="money" type="text" class="form-control" style="width: 80px;"> --- 
				<input type="text" name="endMoney" class="form-control" style="width: 80px;"/>
			</div>
			<button  onclick="MGrid.serchData()" type="button" class="btn btn-default btn-sm"><i class="fa fa-search " ></i> 搜索</button>
			<button  type="reset" class="btn btn-default btn-sm"><i class="fa fa-refresh " ></i> 重置</button>
		</form>
		</p:btn>
	<!-- 搜索框部分en -->
		<div class="option-bar" >
		<p:btn value="dels">
			<button onclick="myGrid.delItems()" type="button" class="btn btn-danger btn-sm"><i class="fa fa-trash" ></i>批量删除</button>
		</p:btn>
		<p:btn value="add">
			<button onclick="openAdd()" type="button" class="btn btn-success btn-sm"><i class="fa fa-plus" ></i>  新增</button>
		</p:btn>
		</div>
		<table id="mgrid" >
			<thead>
				<tr>
					<th data-checkbox="true"></th>
					<th data-formatter="MGrid.indexfn" data-align="center"  data-width="30px" >序号</th>
					<th data-field="userTel" >支付宝帐号</th>
					<th data-field="userName">申请人名称</th>
					<th data-field="money" >提现金额(RMB)</th>
					<th data-field="createTime" data-formatter="getTimes" data-sortable="true">申请时间</th>
					<th data-field="dealUserName" >处理人</th>
					<th data-field="dealTime" data-formatter="getTimes" data-sortable="true">处理时间</th>
					<th data-field="memo">备注</th>
					<th data-field="status" data-formatter="getStatus">申请状态</th>
					<th data-align="center"  data-width="150px" data-field="id" data-formatter="buidOperate">操作</th>
				</tr>
			</thead>
		</table>
	</div>
	
	<script type="text/javascript">
	var myGrid;
		$(function(){
			 myGrid=MGrid.initGrid({
				 url:"${path}/admin/trade/showCashApplyList",
				 delUrl:"${path}/admin/trade/delCashApply"
			 });
		});
		function buidOperate(value, row, index){
			var html='';
			<p:btn value="edit">
			html+='<button class="btn btn-default btn-sm mr-5" onClick="openEdit('+value+')"  title="编辑"><i class="fa fa-edit"></i></buttoun>'
			</p:btn>
			<p:btn value="del">
			html+='<button class="btn btn-default btn-sm" onClick="myGrid.delItem('+value+')" title="删除"><i class="fa fa-lg fa-trash-o"></i></buttoun>';
			</p:btn>
			if(row.status==2){
			<p:btn value="pass">
			html+='<button class="btn btn-default btn-sm mr-5" onClick="approval('+value+')"  title="审核通过"><i class="fa fa-legal"></i></buttoun>'
			</p:btn>
			<p:btn value="invalid">
			html+='<button class="btn btn-default btn-sm" onClick="notDeal('+value+')" title="不予处理"><i class="fa fa-close"></i></buttoun>';
			</p:btn>
			}
			html+=''
			return html; 
		}
		
	function getStatus(value, row, index){
		var status = "";
		switch (value) {
		case 1:
			status = "提现成功";
			break;
		case 2:
			status = "等待处理";
			break;
		case 3:
			status = "不予处理";
			break;
		}
		return status;
	}
	
	function getTimes(value) {
		if(value==null||value==""){
			return "";
		}
		var date = new Date(value);
		return date.getFullYear() + "-" + (date.getMonth() + 1) + "-"
				+ date.getDate();
	}
	
	//通过审核
	function approval(id){
		if(confirm("确定要通过审核吗？")){
			$.ajax({
		        type: "post",
		        url: "${path}/admin/trade/approval",     
		        data: {"id":id},    
		        success: function(data) {
		        	layer.msg("处理成功",{icon:1});
		        },
		        error: function(data) {
		        	layer.msg("网络繁忙，请稍候再试！",{icon:2});
		        }
		    });
	    }else{
	    	
	   }
	}
	
	
	//不予处理
	function notDeal(id) {
		layer.open({
			type : 2,
			title : "处理备注",
			area : [ MUI.SIZE_L, '200px' ],
			content : [ '${path}/admin/trade/toDeal?id='+id]
		}); 
	}
	//初始化日期控件
	$('input[role="datepicker"]').datetimepicker({
		 minView: 'month',
		format : "yyyy-mm-dd",
		weekStart : 1,
		todayBtn : 1,
		autoclose : 1,
		todayHighlight : 1,
		startView : 2,
		forceParse : 0,
		showMeridian : 1,
		language: 'zh-CN' 
	});
	
	</script>
</body>
</html>
